package com.wd.elec.controller.bussiness;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wd.common.core.controller.BaseController;
import com.wd.common.core.domain.HttpResponse;
import com.wd.common.annotation.Log;
import com.wd.common.enums.BusinessType;
import com.wd.elec.domain.StaffInfo;
import com.wd.elec.service.IStaffInfoService;
import com.wd.common.utils.poi.ExcelUtil;


/**
 * 员工信息Controller
 * 
 * @author liumingkun
 * @date 2023-11-08
 */
@RestController
@RequestMapping("/attend/info")
public class StaffInfoController extends BaseController
{
    @Resource
    private IStaffInfoService staffInfoService;

    /**
     * 查询员工信息列表
     */
    @PreAuthorize("@ss.hasPermi('attend:info:list')")
    @GetMapping("/list")
    public HttpResponse list(StaffInfo staffInfo)
    {
        startPage();
        List<StaffInfo> list = staffInfoService.selectStaffInfoList(staffInfo);
        return HttpResponse.successData(getDataTable(list));
    }

    /**
     * 导出员工信息列表
     */
    @PreAuthorize("@ss.hasPermi('attend:info:export')")
    @Log(title = "员工信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StaffInfo staffInfo)
    {
        List<StaffInfo> list = staffInfoService.selectStaffInfoList(staffInfo);
        ExcelUtil<StaffInfo> util = new ExcelUtil<StaffInfo>(StaffInfo.class);
        util.exportExcel(response, list, "员工信息数据");
    }

    /**
     * 获取员工信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('attend:info:query')")
    @GetMapping(value = "/{staffId}")
    public HttpResponse getInfo(@PathVariable("staffId") Long staffId)
    {
        return successData(staffInfoService.selectStaffInfoByStaffId(staffId));
    }

    /**
     * 新增员工信息
     */
    @PreAuthorize("@ss.hasPermi('attend:info:add')")
    @Log(title = "员工信息", businessType = BusinessType.INSERT)
    @PostMapping
    public HttpResponse add(@RequestBody StaffInfo staffInfo)
    {
        return getResult(staffInfoService.insertStaffInfo(staffInfo));
    }

    /**
     * 修改员工信息
     */
    @PreAuthorize("@ss.hasPermi('attend:info:edit')")
    @Log(title = "员工信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public HttpResponse edit(@RequestBody StaffInfo staffInfo)
    {
        return getResult(staffInfoService.updateStaffInfo(staffInfo));
    }

    /**
     * 删除员工信息
     */
    @PreAuthorize("@ss.hasPermi('attend:info:remove')")
    @Log(title = "员工信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{staffIds}")
    public HttpResponse remove(@PathVariable Long[] staffIds)
    {
        return getResult(staffInfoService.deleteStaffInfoByStaffIds(staffIds));
    }
}
